import java.util.*;

public class Test {
    public static void main(String[] args) {
/*        int[] arr = {10,5,12,45,32,20,18};
        int[] a = Arrays.copyOf(arr,5);
        System.out.println(Arrays.toString(a));
        int[]  b = new int[9];
        Arrays.fill(b,2);
        System.out.println(Arrays.toString(b));

        String str  = "";
        str.*/
/*        String str = "         aaaaabbbbba     ";
        String str1 = "         aaabbbba     ";

        System.out.println(str.trim());*/
/*        int num = 100;
        String str = String.valueOf(num);  // str = "100"*/
/*        String str = "apple,banana,orange";
        String[] arr = str.split(",");  // arr = ["apple", "banana", "orange"]
        System.out.println(Arrays.toString(arr));
        String result = String.join(" ", "apple", "banana", "orange","ss");  // "apple,banana,orange"
        System.out.println(result);*/
/*        StringBuffer stringBuffer = new StringBuffer(); // 默认容量为16
        stringBuffer.append("hello");
        String str = stringBuffer.toString(); //hello
        System.out.println(str);*/
/*        ArrayList<Integer> list2 = new ArrayList<>();
        LinkedList<Integer> list = new LinkedList<>();
        list.add(1);
        list.add(1);
        list.add(1);
        list.add(2);
        list.add(3);
        list.add(4);
        list.add(5);
        list.remove(0); // 2 3 4 5
        System.out.println(list);*/
/*        Stack<Integer> stack = new Stack<>();
        stack.push(10);
        stack.push(20);
        stack.push(30);*/
        Queue<Integer> queue = new LinkedList<>();
// 或使用 ArrayDeque，性能更好
/*        Queue<Integer> queue1 = new ArrayDeque<>();
        PriorityQueue<Integer> maxHeap = new PriorityQueue<>((a,b)-> b - a);
        PriorityQueue<Integer> max = new PriorityQueue<>(Comparator.reverseOrder());
        maxHeap.offer(1);
        maxHeap.offer(11);
        maxHeap.offer(10);
//        for(int x :maxHeap) {
//            System.out.println(x);
//        }
        Iterator<Integer> iterator = maxHeap.iterator();
        while (iterator.hasNext()) {
            System.out.println(iterator.next());
        }
        */
        /*
        Set<String> keySet = hash.keySet();
        System.out.println(keySet);
        Collection<Integer> values = hash.values();
        System.out.println(values);
        Set<Map.Entry<String, Integer>> entrySet = hash.entrySet();
        System.out.println(entrySet);
*/

        Map<String,Integer> hash = new HashMap<>();
        hash.put("hhh",1);
        hash.put("ggg",2);
        hash.put("www",3);
        //遍历key
        for(String key :hash.keySet()) {
            System.out.print(key+" ");
        }
        System.out.println();
        //遍历values
        for(Integer value :hash.values()) {
            System.out.print(value+" ");
        }
        System.out.println();
        //遍历整个map
        for (Map.Entry<String,Integer> entry :hash.entrySet()) {
            System.out.println(entry.getKey() + ":" + entry.getValue());
        }
        //lambda 遍历map
        System.out.println();
        hash.forEach((key,value)->{
            System.out.println(key + ":" + value);
        });
    }
}
